/*
* Copyright (c)  2017, ueboot.com
* All rights reserved.
* 2017-10-14 21:04:13
*/
package com.ueboot.weishop.repository.activity;

import com.ueboot.weishop.entity.activity.ActivityEntity;
import com.ueboot.core.repository.BaseRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * Created by Neel  on 2017-10-14 21:04:13.
 *
 * @since 2.0 by autocode
 */
@Repository
public interface ActivityRepository extends BaseRepository<ActivityEntity, Long> {
	/**
	 * 根据类型查询不同的活动列表
	 *
	 * @param pageable 分页数据
	 * @param type     类型，参加模型类的定义
	 * @return
	 */
	Page<ActivityEntity> findByType(Pageable pageable, String type);

	/**
	 * 根据活动代码查询活动
	 *
	 * @param sn 活动代码
	 * @return
	 */
	ActivityEntity findBySn(String sn);

	/**
	 * 查询最新一次添加的活动信息
	 *
	 * @param activitySN 活动编号
	 * @param type       活动类型
	 * @param status     活动状态
	 * @return 查询出来的第一条数据
	 */
	ActivityEntity findTopBySnAndTypeAndStatusOrderByFirstInsertDesc(String activitySN, String type, String status);

	List<ActivityEntity> findByTypeAndStatusOrderByStartTimeAsc(String type, String statusOpening);

	List<ActivityEntity> findByTypeAndStatusAndStartTimeBetweenAndEndTimeBetween(String type, String statusOpening, Date startTimeStart, Date startTimeEnd, Date endTimeStart, Date endTimeEnd);

	ActivityEntity findById(Long id);
}
